package com.woniuxy;

import io.jsonwebtoken.JwtBuilder;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;

import java.util.Date;

/**
 * @Author: 马宇航
 * @Todo: 入门简单了解即可
 * @DateTime: 22/09/05/0005 12:03
 * @Component: 成都蜗牛学苑
 **/
public class CreateJWTDemo {
    private final  static  long EXPIRATION = 300L;
    //了解JWT长相
    public static void main(String[] args) {
        long l = System.currentTimeMillis();
        long ex = l+EXPIRATION*1000;
        JwtBuilder jwtBuilder = Jwts.builder().setId("woniuxy").setSubject("管理员").setIssuedAt(new Date())
                //签名算法
                .signWith(SignatureAlgorithm.HS256, "mayuhang")
                //过期时间：30s
                .setExpiration(new Date(ex))
                .claim("account","admin")
                .claim("status","Y");
        System.out.println(jwtBuilder.compact());
    }
}
